package com.cunshe.web.manage;

import com.cunshe.common.ResponseVO;
import com.cunshe.config.annotation.Login;
import com.cunshe.domain.Banner;
import com.cunshe.entity.vo.BannerUpdateVO;
import com.cunshe.service.BannerService;
import com.sunkee.commons.utils.ConvertUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页横幅
 * @author xiao
 */
@Api(tags = "首页横幅")
@Login
@RestController
@RequestMapping(value = "/manage/banner")
public class BannerController {

    @Autowired
    private BannerService bannerService;

    /** 修改 */
    @ApiOperation(value = "修改")
    @PostMapping(value = "update")
    public ResponseVO update(@RequestBody @Validated BannerUpdateVO vo) {
        Banner record = ConvertUtil.copyProperties(vo, Banner.class);
        bannerService.update(record);
        return ResponseVO.success();
    }

    /** 查询列表 */
    @ApiOperation(value = "查询列表")
    @PostMapping(value = "list")
    public ResponseVO list(Banner record) {
        List<Banner> list = bannerService.list(record);
        return ResponseVO.success(list);
    }

}